package cn.xhb.mapper;

import cn.xhb.domain.User;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;
@Repository
public interface UserMapper {
    @Select("select * from sys_user")
    List<User> findAll();
    @Insert("insert into sys_user(username,email,password,phoneNum) values(#{username},#{email},#{password},#{phoneNum})")
    @Options(useGeneratedKeys = true,keyProperty = "id")
    Long save(User user);
    @Insert("insert into sys_user_role values(#{userId},#{roleId})")
    void saveUserRoleRel(@Param("userId") Long userId,@Param("roleId") Long roleId);
    @Delete("delete from sys_user_role where userId=#{userId}")
    void delUserRoleRle(Long userId);
    @Delete("delete from sys_user where id=#{userId}")
    void del(Long userId);
}
